
#import <QuartzCore/QuartzCore.h>
#import "ButtonCell.h"

@implementation ButtonCell

- (void)initCellWithBackgroundImage:(UIImage *)backgroundImage backgroundImageSelected:(UIImage *)backgroundImageSelected title:(NSString *)title
{
    UIImage* buttonImage = [backgroundImage stretchableImageWithLeftCapWidth:14.0 topCapHeight:0.0];
    UIImage* buttonHighlightImage = [backgroundImageSelected stretchableImageWithLeftCapWidth:14.0 topCapHeight:0.0];
    
    self.button.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:15.0];
    self.button.titleLabel.textColor = [UIColor whiteColor];
    self.button.titleLabel.layer.shadowColor = [UIColor blackColor].CGColor;
    self.button.titleLabel.layer.shadowOpacity = 0.1;
    self.button.titleLabel.layer.shadowRadius = 0;
    self.button.titleLabel.layer.shadowOffset = CGSizeMake(0.0f, -0.9f);
    
    [self.button setTitle:title forState:UIControlStateNormal];
    
    [self.button setBackgroundImage:buttonImage forState:UIControlStateNormal];
    [self.button setBackgroundImage:buttonHighlightImage forState:UIControlStateHighlighted];
    [self.button setBackgroundImage:buttonHighlightImage forState:UIControlStateSelected];
    
    [self.button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

#pragma mark - selectors
- (void)buttonPressed
{
    [self.delegate buttonCellButtonPressed];
}

@end
